package com.example.javafx.复选框;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Tooltip;
import javafx.scene.text.Font;
import javafx.stage.Stage;

/**
 * 复选框
 */
public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Scene scene = new Scene(new Group());
        primaryStage.setTitle("Tooltip Sample");
        primaryStage.setWidth(300);
        primaryStage.setHeight(150);

        final CheckBox cb = new CheckBox("checkbox");
        final Tooltip tooltip = new Tooltip("$ tooltip");
        tooltip.setFont(new Font("Arial",16));
        cb.setTooltip(tooltip);
        cb.selectedProperty().addListener((observable, oldValue, newValue) -> {
            System.out.println(cb.isSelected());
        });

        ((Group)scene.getRoot()).getChildren().add(cb);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
